﻿using System.Drawing;
using System.Web.Mvc;
using XCaptcha.Web.Mvc;

namespace Eacademy.Controllers
{
    public class CaptchaController : Controller
    {


        [HttpGet]
        public string EncryptedCaptchaSolution()
        {
            var textGenerator = new XCaptcha.RandomTextGenerator();
            return textGenerator.CreateRandomUrlEncodedEncrypedText(Constants.CaptchaKey, 4);

        }



        [DecryptSolution(Constants.CaptchaKey)]
        public ActionResult CaptchaImage(string solution)
        {
            Color[] randomColors = new[] {
                                SystemColors.Highlight, 
                                Color.FromArgb(0xF0, 0x66, 0x01), 
                                Color.FromArgb(0x5B, 0x5A, 0x5A), 
                                Color.Orange, 
                                Color.FromArgb(0x55, 0x82, 0x00), 
                                Color.FromArgb(0x3C, 0x7F, 0xAF), 
                                Color.FromArgb(0x65, 0xAD, 0xD3), 
                                Color.FromArgb(0x66, 0x66, 0x66) 

                              };

            return new CaptchaImageResult(solution, randomColors);
            //return new CaptchaImageResult(solution);

        }



    }
}
